import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class testexec {

	
	public static void main(String[] argv) throws Exception {
	
		System.out.println("Starting exec command");
		System.out.println(callex("ping -c 4 rp-1"));	
		
	}
		public static String callex(String execCommand) throws Exception {
		
		
		try {
		Process p = Runtime.getRuntime().exec(execCommand);
		p.waitFor();
		BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));

		String line;
		String line2 = "";
		
		while ((line = input.readLine()) != null) {
		  line2 = line2 + "\n" + line;
		}
		
		 return line2;
		
	}catch( IOException ex ){
		return ex.toString();
		
		//Validate the case the file can't be accesed (not enought permissions)

	}

}
}